package cn.com.sbell.vss.csg.vap;

import org.dom4j.Element;

import cn.com.sbell.vss.VssConstants;
import cn.com.sbell.vss.VssException;
import cn.com.sbell.vss.csg.vap.bean.IpCameraAlarmCofig;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.BeanValidator;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;

public class SetIpCameraMotionDetect extends ProtectedVsCommander {

	protected Element executeCommand(VsClient vsClient,
			PropertiesHolder holder, Element root) {
		IpCameraAlarmCofig alarmConfig = (IpCameraAlarmCofig) holder
				.populate(new IpCameraAlarmCofig());
		BeanValidator.validateNotNull(alarmConfig, new String[] { "thresh",
				"sense" });
		if(!vsClient.setIpcameraMotionDetect(alarmConfig)){
			throw new VssException(VssConstants.CODE_SET_IPCAMERA_MOTION_DETECT_FAILED);
		}
		return root;
	}

}
